package com.project.mapper;

import com.project.bean.ClassBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author lyl
 * description:
 */
public interface IClassMapper {

    /**
     * 分页显示
     *
     * @return 班级集合
     */
    @Select("select * from t_class")
    @ResultMap("classMap")
    List<ClassBean> findAllByPage();

    /**
     * 添加班级
     *
     * @param classBean 班级对象
     */
    @Insert("insert into t_class(c_className,c_creatDate,c_teacher)values(#{className},#{creatDate},#{teacher})")
    void add(ClassBean classBean);

    /**
     * 更新该id下带班老师姓名
     *
     * @param classId
     * @param teacherName
     */
    @Update("update t_class set c_teacher = #{teacherName} where pk_classId =#{classId}")
    void updateClassTeacher(@Param("classId") int classId, @Param("teacherName") String teacherName);

    /**
     * 根据传入的班级id查找班级对象
     *
     * @param classId
     * @return
     */
    @Select("select * from t_class where pk_classId = #{classId}")
    @ResultMap("classMap")
    ClassBean findById(@Param("classId") int classId);

    /**
     * 根据班级id删除班级
     *
     * @param classId
     */
    @Delete("delete from t_class where pk_classId = #{classId}")
    void del(@Param("classId") int classId);
}
